package hdoj;

import java.util.Scanner;

//求n个序列中和最大和的连续序列
public class MaxSumOfContinuousHD1003 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int testCount = scanner.nextInt();
		int[] a = new int[100000];
		while (testCount-- != 0) {
			getMaxNum(a);
		}
		scanner.close();
	}

	// 从n个序列中找最大的连续子序列的和
	public static int getMaxNum(int[] a) {
		int maxSum = 0;
		int curSum = 0; // 记录当前的和
		for (int i = 0; i < a.length; i++) {
			if (curSum < 0) {
				curSum = a[i];
			}else {
				curSum += a[i];
			}
			if (curSum > maxSum) {
				maxSum = curSum;
			}
			System.out.println(maxSum);
		}
		return maxSum;
	}
}
